package com.bw.mvvm_common.mvvm.utils;

import android.database.sqlite.SQLiteDatabase;


import com.bw.mvvm_common.BaseApplication;
import com.bw.mvvm_common.dao.DaoMaster;
import com.bw.mvvm_common.dao.DaoSession;
import com.bw.mvvm_common.dao.GoodBeanDao;
import com.bw.mvvm_common.dao.UserBeanDao;

public
/**
 * @author Lishaohe
 * @description:
 * @date :2021/10/20 0020 下午 3:19
 *
 */
class GreenDaoUtils {

    public static GreenDaoUtils greenDaoUtils;

    public static GreenDaoUtils getGreenDaoUtils() {
        if (greenDaoUtils==null){
            synchronized (GreenDaoUtils.class){
                greenDaoUtils = new GreenDaoUtils();
            }
        }
        return greenDaoUtils;
    }

    //用户数据库
    public UserBeanDao green(){
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(BaseApplication.getApplication(), "user.db");
        SQLiteDatabase readableDatabase = devOpenHelper.getReadableDatabase();
        DaoMaster daoMaster = new DaoMaster(readableDatabase);
        DaoSession daoSession = daoMaster.newSession();
        UserBeanDao userBeanDao = daoSession.getUserBeanDao();
        return userBeanDao;

    }
    //商品数据库
    public GoodBeanDao good(){
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(BaseApplication.getApplication(), "goods.db");
        SQLiteDatabase readableDatabase = devOpenHelper.getReadableDatabase();
        DaoMaster daoMaster = new DaoMaster(readableDatabase);
        DaoSession daoSession = daoMaster.newSession();
        GoodBeanDao goodBeanDao = daoSession.getGoodBeanDao();
        return goodBeanDao;

    }
}
